-- SCAN EXISTING CARDS TO SEE IF AN ACCOUNT FOR THIS CLIENT ALREADY
-- EXISTS. IF SO, THEN SKIP CONFLICTS PROCEDURE AND INCREMENT
-- EXISTING ACCOUNT NUMBER BY 1 TO ASSIGN NEW SUBACCOUNT.
on scanForOldClient
global temp1,temp2,adrs,tphone
set cursor to 4
set lockScreen to true
show msg at 17,246
put "Now searching stack to see if this is an existing client"
put line 1 of field "Client Name" into oldClient
push card
put "abcd" into temp1
put 1 into temp2
repeat with y = 2 to the number of cards -1
go to card y
if line 1 of field "Client Name" contains oldClient then
put field "Client Number" into temp1
put field "Address" into adrs
put field "Phone" into tphone
set numberFormat to 000
add 1 to temp2
end if
end repeat
pop card
if temp1 contains "abcd" then
scanForConflicts -- no account yet for this client
else
assignNewSubaccount -- account already exists
end if
end scanForOldClient
-- HAVEN'T FOUND AN EXISTING ACCOUNT FOR THIS CLIENT;
-- SCAN ADVERSE PARTY FIELD OF ALL PREVIOUS CARDS FOR CONFLICTS
on scanForConflicts
set cursor to 4
set lockScreen to false
push card
repeat with i = 1 to the number of words of field "Client Name"
show msg at 17,246
put word i of field "Client Name" into conflict
if conflict contains "Mr." or conflict contains "Mrs." or conflict contains "Miss" or conflict contains "Ms." or conflict contains "and" or conflict contains "of" then next repeat
put "Searching for conflict with:" && quote & conflict & quote
repeat with j = 2 to the number of cards
go to card j
if conflict is in field "Adverse" then
beep 3
put "Conflict found with:" && quote & conflict & quote into msg
wait 1 seconds
put "NOTE: Answering " & quote & "No" & quote & " will delete new card"
answer "Do you want to continue search for conflicts?" with "No" or "Yes"
if it is "No" then
pop card
doMenu Delete Card
hide msg
exit scanForConflicts
else
put "Searching for conflict with:" && quote & conflict & quote
next repeat
end if
else
next repeat
end if
end repeat
end repeat
pop card
assignClientNumber
end scanForConflicts
-- NO CONFLICTS FOUND WITH NEW CLIENT; ASSIGN A NEW ACCOUNT NUMBER
on assignClientNumber -- format is xxyy.zzz
put "Now assigning a new account number to this client"
if word 1 of field "Client Name" contains "Mr" or word 1 of field "Client Name" contains "Ms" or word 1 of field "Client Name" contains "Miss" then
put char 1 of last word of field "Client Name" into temp3
else
put char 1 of line 1 of field "Client Name" into temp3
end if
set numberFormat to 00
put the charToNum of temp3 - 64 into temp3 -- ASCII equivalent
set numberFormat to 00
put the number of cards-1 into temp4 -- number accounts consecutively
add 0 to temp4
put temp3 & temp4 & ".001" into field "Client Number" -- subaccount #
hide msg
set the name of this card to field "Client Number"
end assignClientNumber
on assignNewSubaccount
global temp1,temp2,adrs,tphone
put "Now assigning a new subaccount number for this client"
repeat 3 times
delete last char of temp1 -- strip subaccount numbers
end repeat
put temp1 & temp2 into field "Client Number"
-- temp1 is existing account number; temp2 # of existing subaccounts+1
put adrs into field "Address"
put tphone into field "Phone"
hide msg
set the name of this card to field "Client Number"
end assignNewSubaccount
-- part 3 (field)
-- low flags: 01
-- high flags: 4000
-- rect: left=423 top=44 right=58 bottom=493
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Client Number
----- HyperTalk script -----
-- part 4 (field)
-- low flags: 00
-- high flags: 4000
-- rect: left=112 top=113 right=166 bottom=350
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Address
-- part 5 (field)
-- low flags: 00
-- high flags: 4000
-- rect: left=112 top=177 right=191 bottom=349
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Phone
-- part 6 (field)
-- low flags: 00
-- high flags: 4000
-- rect: left=112 top=196 right=210 bottom=350
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Matter
-- part 7 (field)
-- low flags: 00
-- high flags: 4000
-- rect: left=124 top=250 right=264 bottom=350
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Referral
-- part 9 (field)
-- low flags: 00
-- high flags: 4000
-- rect: left=124 top=267 right=281 bottom=163
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Fee_Quote
-- part 10 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=358 top=76 right=90 bottom=406
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Sort
----- HyperTalk script -----
on mouseUp
sort by field "Client Number"
end mouseUp
-- part 11 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=426 top=76 right=90 bottom=478
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: New
----- HyperTalk script -----
on mouseUp
go to last card
doMenu "New Card"
end mouseUp
-- part 13 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=358 top=92 right=108 bottom=480
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Time Slips
----- HyperTalk script -----
on mouseUp
go to stack "Time Slips"
end mouseUp
-- part 8 (field)
-- low flags: 00
-- high flags: 4000
-- rect: left=151 top=285 right=325 bottom=384
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Adverse
----- HyperTalk script -----
-- part 17 (field)
-- low flags: 01
-- high flags: 4007
-- rect: left=356 top=177 right=248 bottom=490
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: Descrip
-- part 20 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=359 top=126 right=142 bottom=481
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Adjust Fees
----- HyperTalk script -----
on mouseUp
ask "Please enter new hourly rate:" with "125"
put it into newFee
if newFee Γëá field "Fee_Quote" then
set cursor to 4
set lockScreen to true
set lockMessages to true
put newFee into field "Fee_Quote"
put field "Client Number" into clNum
push card
go to stack "Time Slips"
repeat with x = 2 to the number of cards
go to card x
if field "Client Number" contains clNum then
put newFee into field "Hourly"
send "computeBill quarterHours" to target
end if
end repeat
pop card
send mouseUp to bkgnd button "Amt. Due"
set lockScreen to false
set lockMessages to false
end if
end mouseUp
-- part 21 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=359 top=143 right=158 bottom=481
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Amt. Due
----- HyperTalk script -----
on mouseUp
global accumulateFees,accumulateDisb
put field "Client Number" into clNum
set cursor to 4
set lockScreen to true
set lockMessages to true
push card
go to stack "Time Slips"
put 0 into accumulateFees
put 0 into accumulateDisb
repeat with x = 2 to the number of cards
go to card x
if field "Client Number" contains clNum then
set numberFormat to 0.00
add field "Total Bill" to accumulateFees
end if
end repeat
go to stack "Disbursements"
put 0 into accumulateDisb
repeat with x = 2 to the number of cards
go to card x
if field "Client Number" contains clNum then
add field "Total Disb" to accumulateDisb
end if
end repeat
pop card
set lockScreen to false
set lockMessages to false
put "Balance Outstanding:" into line 1 of field "Descrip"
put "Fees: $" & accumulateFees into line 2 of field "Descrip"
put "Disbursements: $" & accumulateDisb into line 3 of field "Descrip"
end mouseUp
-- part 22 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=360 top=159 right=173 bottom=481
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Prepare Bill
----- HyperTalk script -----
on mouseUp
global clNumber,atty,hrs,rte,totfees,header,bodyofBill,bodyofDisb, accumulateFees, accumulateDisb
set lockRecent to true
set lockScreen to true
set lockMessages to true
set cursor to 4
get hilite of button "All Bills" of card "Configure"
if it is true then
checkConfiguration
else
put "false" into atty
put "false" into hrs
put "false" into rte
put "false" into totfees
end if
constructHeader
assembleFees
assembleDisbursements
writeBill
set lockRecent to false
set lockScreen to false
set lockMessages to false
play boing
end mouseUp
on checkConfiguration
-- SET FLAGS FOR BILLING FORMAT; APPARENTLY, THIS MUST BE DONE BEFORE
-- SWITCHING TO ANOTHER STACK
global atty,hrs,rte,totfees
get hilite of button "Hours" of card "Configure"
if it is true then
put "true" into hrs
else
put "false" into hrs
end if
get hilite of button "Rate" of card "Configure"
if it is true then
put "true" into rte
else
put "false" into rte
end if
get hilite of button "Total Fees" of card "Configure"
if it is true then
put "true" into totfees
else
put "false" into totfees
end if
get hilite of button "Attorney" of card "Configure"
if it is true then
put "true" into atty
else
put "false" into atty
end if
end checkConfiguration
on constructHeader
-- CONSTRUCT LETTERHEAD AND MAILING ADDRESS INFORMATION
global header,clNumber
put return & return & return & tab & tab & tab & "Peter B. Nagel" & return into header
put tab & tab & tab & "710 Dahlia Street" & return after header
put tab & tab & tab & "Denver, Colorado 80220" & return after header
put tab & tab & tab & "CompuServe 75036,3423" & return after header